package com.hskj.rabbitmq.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class RabbitMQUtil {
    public static Connection getConnection() throws  Exception{
        //创建连接工厂
        ConnectionFactory connectionFactory = new ConnectionFactory();
        //连接的设置
        connectionFactory.setHost("192.168.6.144");
        connectionFactory.setPort(5672);
        connectionFactory.setVirtualHost("/");
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        //创建连接
        Connection connection = connectionFactory.newConnection();
        return connection;
    }
}
